home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group00b.txt / 000137_icon-group-sender_Thu Nov 2 07:58:06 2000.msg < prev    next >
Internet Message Format  |  2001-01-03  |  4KB

  1. Return-Path: <icon-group-sender>
  2. Received: (from root@localhost)
  3.     by baskerville.CS.Arizona.EDU (8.11.1/8.11.1) id eA2Etn608361
  4.     for icon-group-addresses; Thu, 2 Nov 2000 07:55:49 -0700 (MST)
  5. Message-Id: <200011021455.eA2Etn608361@baskerville.CS.Arizona.EDU>
  6. From: "Ian Trudel" <ian.trudel@tr.cgocable.ca>
  7. To: <Chris.D.Tenaglia@jci.com>, <icon-group@cs.arizona.edu>
  8. Subject: CGI Programming (was: favorites)
  9. Date: Wed, 1 Nov 2000 20:29:08 -0500
  10. X-Priority: 3
  11. X-MSMail-Priority: Normal
  12. X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600
  13. Errors-To: icon-group-errors@cs.arizona.edu
  14. Status: RO
  15. Content-Length: 3359
  16.  
  17. Speaking of this, we're doing a lot of CGI programming using Icon at Mecenia
  18. Organization. I've been updating cgi.icn and we will probably release a new
  19. updated version soon, having some bug fixes and support for cookies, custom
  20. header/footer/stylesheet and so forth. We will probably update
  21. http://ringer.cs.utsa.edu/research/icon/cgi.html (if Clinton Jefferey and
  22. Jonathan Vallejo don't mind) as well. If you have code snipet you'd like to
  23. add, just drop me an email.
  24.  
  25. regards,
  26. ian
  27. ----------------------------------------------------------------
  28. *squeak* *squeak* said the little mouse while eating a java hog.
  29. Ian Trudel, mailto:ian.trudel@tr.cgocable.ca
  30.  
  31.  
  32. ----- Original Message -----
  33. From: <Chris.D.Tenaglia@jci.com>
  34. To: <icon-group@CS.Arizona.EDU>
  35. Sent: Tuesday, October 31, 2000 5:29 PM
  36. Subject: favorites
  37.  
  38.  
  39. > Since this list is getting more active here are some of my favorite
  40. > procedures.
  41. > The IPL is full of goodies. Some below may be there, but recently I have
  42. > been
  43. > doing more with the web and CGI, and it's great to build software when you
  44. > have
  45. > a giant software chip library and are fairly familiar with it.  Just a
  46. > couple includes,
  47. > a main() and you're done. The procedures below I use extensively, every
  48. day
  49. > and they sure help.
  50. >
  51. > Chris Tenaglia, tech analyst, jci
  52. >
  53. >
  54. > #
  55. > # parse a string into a list with respect to a delimiter
  56. > #
  57. > procedure parse(line,delims)
  58. >   static chars
  59. >   chars  := &cset -- delims
  60. >   tokens := []
  61. >   line ? while tab(upto(chars)) do put(tokens,tab(many(chars)))
  62. >   return tokens
  63. >   end
  64. >
  65. > #
  66. > # prompt for an input string
  67. > #
  68. > procedure input(prompt)
  69. >   writes(prompt)
  70. >   return read()
  71. >   end
  72. >
  73. > #
  74. > # parse a cgi query string into a table
  75. > #
  76. > procedure cgiparse(text)
  77. >   parts := parse(text,'&')
  78. >   lookup:= table("n/a")
  79. >   every part := !parts do
  80. >     {
  81. >     var := parse(part,'=')[1]
  82. >     val := map(parse(part,'=')[2],"+"," ") | ""
  83. >     lookup[unurl(var)] := map(unurl(val),"\r"," ")
  84. >     }
  85. >   return lookup
  86. >   end
  87. >
  88. > #
  89. > # error handler if program called wrong
  90. > #
  91. > procedure error()
  92. >   write("content-type: text/html")
  93. >   write("")
  94. >   write("<HTML>")
  95. >   write("<HEAD><TITLE>BAD CALL</TITLE></HEAD>")
  96. >   write("<BODY BGCOLOR=80000><font color=#ffffff>")
  97. >   write("<PRE><B>\n\n\n")
  98. >   write("PROGRAM CALLED INCORRECTLY")
  99. >   write("\n\n\n</B></PRE>")
  100. >   write("</body>")
  101. >   stop("</html>")
  102. >   end
  103. >
  104. > #
  105. > # This procedure maps the wierd characters out of cgi query strings
  106. > #
  107. > procedure unurl(text)
  108. >   static  hex
  109. >   initial {
  110. >           hex := table("")
  111. >           hex["0"] := 0 ; hex["1"] := 1 ; hex["2"] := 2 ; hex["3"] := 3
  112. >           hex["4"] := 4 ; hex["5"] := 5 ; hex["6"] := 6 ; hex["7"] := 7
  113. >           hex["8"] := 8 ; hex["9"] := 9 ; hex["a"] := 10; hex["A"] := 10
  114. >           hex["b"] := 11; hex["B"] := 11; hex["c"] := 12; hex["C"] := 12
  115. >           hex["d"] := 13; hex["D"] := 13; hex["e"] := 14; hex["E"] := 14
  116. >           hex["f"] := 15; hex["F"] := 15
  117. >           }
  118. >   work  := map(text,"+"," ")
  119. >   cache := []
  120. >   every i := 1 to *work do if work[i] == "%" then put(cache,i)
  121. >   while i := pull(cache) do
  122. >    {
  123. >    nyb1 := work[i+1]
  124. >    nyb2 := work[i+2]
  125. >    if (nyb1 == "") | (nyb2 == "") then next
  126. >    raw  := hex[nyb1] * 16 + hex[nyb2]
  127. >    byte := char(raw)
  128. >    work[i+:3] := byte
  129. >    }
  130. >   return work
  131. >   end
  132. >
  133. >
  134. >
  135.  
  136.